import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue';
import UserListView from '../views/UserListView';
import UserProfileView from '../views/UserProfileView';
import LoginView from '../views/LoginView';
import RegisterView from '../views/RegisterView';
import NotFoundView from '../views/NotFoundView';

const routes = [
  {
    path: '/myspace/',
    name: 'HomeView',
    component: HomeView
  },
  {
    path: '/myspace/userlist/',
    name: 'UserListView',
    component: UserListView
  },
  {
    path: '/myspace/userprofile/:userId/', // :表示后面接的是参数
    name: 'UserProfileView',
    component: UserProfileView
  },
  {
    path: '/myspace/login/',
    name: 'LoginView',
    component: LoginView
  },
  {
    path: '/myspace/register/',
    name: 'RegisterView',
    component: RegisterView
  },
  {
    path: '/myspace/NotFound/',
    name: 'NotFoundView',
    component: NotFoundView
  },
  {
    path:'/myspace/:catchAll(.*)',//catchAll表示正则表达式,
    component: NotFoundView
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

export default router
